use std::io::Error;
use inquire::Text;

#[derive(PartialEq)]
#[derive(Debug)]
pub enum ProjectType {
    Micro,
    H5,
}

#[derive(Debug)]
pub struct ProjectInfo {
    pub project_name: String,
    pub project_type: ProjectType,
}

pub fn command_interaction() -> Result<ProjectInfo, Error> {
    let hint_text1 = "\x1B[31m输入1表示创建微架构项目!\x1B[0m";
    let hint_text2 = "\x1B[31m输入2表示创建h5项目!\x1B[0m";
    println!("{}", hint_text1);
    println!("{}", hint_text2);
    let project_type_input  = Text::new("请输入项目类型(请输入1或者2)：").prompt().unwrap();
    let project_type = match project_type_input.as_str() {
        "1" => ProjectType::Micro,
        "2" => ProjectType::H5,
        _ => return Err(Error::new(std::io::ErrorKind::InvalidInput, "Invalid project type")),
    };

    let project_name = Text::new("请输入项目名称：").prompt().unwrap();
    let project_info = ProjectInfo {
        project_type,
        project_name,
    };
    Ok(project_info)
    // return project_info;
}
